@echo off
REM AI-Powered SSH Terminal - Conda Environment Setup Script for Windows
REM This script sets up the conda environment for the project

echo ========================================
echo  AI-Powered SSH Terminal Setup
echo ========================================

REM Check if conda is installed
conda --version >nul 2>&1
if %errorlevel% neq 0 (
    echo ERROR: Conda is not installed or not in PATH
    echo Please install Miniconda or Anaconda first
    echo Download from: https://docs.conda.io/en/latest/miniconda.html
    pause
    exit /b 1
)

echo Found Conda installation
conda --version

REM Create conda environment from environment.yml
echo.
echo Creating conda environment 'ai-terminal'...
conda env create -f environment.yml

if %errorlevel% neq 0 (
    echo ERROR: Failed to create conda environment
    echo Try running: conda env remove -n ai-terminal
    echo Then run this script again
    pause
    exit /b 1
)

echo.
echo ========================================
echo  Setup Complete!
echo ========================================
echo.
echo To activate the environment:
echo   conda activate ai-terminal
echo.
echo To start the server:
echo   python start_server.py
echo.
echo To deactivate when done:
echo   conda deactivate
echo.

REM Ask if user wants to activate immediately
set /p activate="Activate environment now? (y/n): "
if /i "%activate%"=="y" (
    echo.
    echo Activating environment...
    call conda activate ai-terminal
    echo Environment activated! You can now run: python start_server.py
    cmd /k
) else (
    echo.
    echo Remember to run 'conda activate ai-terminal' before using the application
)

pause